<template>
	<view>
		<zero-loading type="circle" v-if="loading"></zero-loading>
		<view class="title cu-bar solid-bottom">
			<view class="action">
				<text :class="online>0?'text-olive':'text-gray'" class="iconfont icon-siweiqi  padding-right-xs"></text>
				<view v-if="online>0" class='cu-tag radius sm line-olive '>在线</view>
				<view v-if="online==0" class='cu-tag radius sm line-gray'>离线</view>
				<view v-if="alarm_bit0 && alarm_bit0>0" class='cu-tag radius sm line-orange'>堵料</view>
				<view v-if="alarm_bit1 && alarm_bit1>0" class='cu-tag radius sm line-orange'>堵水</view>
				<view v-if="alarm_bit2 && alarm_bit2>0" class='cu-tag radius sm line-orange'>探针异常</view>
				<view v-if="alarm_bit3 && alarm_bit3>0" class='cu-tag radius sm line-orange'>触碰异常</view>
				<view v-if="alarm_bit4 && alarm_bit4>0" class='cu-tag radius sm line-orange'>电机异常</view>
				<view v-if="alarm_bit5 && alarm_bit5>0" class='cu-tag radius sm line-orange'>下水异常</view>
				<view v-if="alarm_bit6 && alarm_bit6>0" class='cu-tag radius sm line-orange'>空转</view>
				<!-- <view  class='cu-tag radius sm line-white'>SN:{{sn}}</view> -->
				<!-- <view  class='cu-tag radius sm line-white'>版本号:{{version}}</view> -->
			</view>
			<view class="action" @tap="loadAll()">
				<text class="cuIcon-refresh text-icon-size text-olive "></text>
				<!-- <view  class='cu-tag radius sm line-gray'>SN:{{feedNode.sn}}</view>
				<view  class='cu-tag radius sm line-gray'>SN:{{feedNode.version}}</view> -->
			</view>
		</view>
		<scroll-view scroll-y="true" class="scroll-Y" :style='{ height: scrollHeight }'>
			<view class="flex">
				<view class="back_forward_btn flex align-center justify-center" hover-class="opcity"
					hover-stay-time="150" @tap="onPreDay()">
					<text v-if="has_pre_day" class="cuIcon-back text-olive text-xl"></text>
				</view>
				<view class="bg-pannel margin-top" style="width: calc(100% - 80px);">
					<view class="padding">
						<view class="flex justify-center align-center">
							<view class=" text-lg text-bold text-grey">{{date}}</view>
						</view>
						<view class="flex padding-top-sm">
							<view class="flex-sub  text-center">
								<view class="text-grey text-sm">状态</view>
							</view>
							<view class="flex-sub  text-center">
								<view class="text-grey text-sm">采食量</view>
							</view>
							<view class="flex-sub text-center">
								<view class="text-grey text-sm">目标量</view>
							</view>
						</view>

						<view class="flex padding-top-xs">
							<view class="flex-sub  text-center">
								<text class=" text-md">
									{{hisItem.mode_day}}
								</text>
							</view>
							<view class="flex-sub  text-center">
								<text class=" text-md">
									{{hisItem.feed}}
								</text>
								<text class="text-gray text-xs padding-left-xs">kg</text>
							</view>
							<view class="flex-sub text-center">
								<text class=" text-md">
									{{hisItem.max_feed}}
								</text>
								<text class="text-gray text-xs padding-left-xs">kg</text>
							</view>
						</view>
					</view>
				</view>
				<view class="back_forward_btn flex align-center justify-center" hover-class="opcity"
					hover-stay-time="150" @tap="onNextDay()">
					<text v-if="has_next_day" class="cuIcon-right text-olive text-xl"></text>
				</view>
			</view>

			<view class="cu-bar solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-titles text-olive"></text>
					<text class="text-white text-md">详细信息</text>
				</view>
				<view class="action" @tap="showModal()">

					<text class="text-olive text-md">设置</text>
					<text class="cuIcon-moreandroid text-sm text-icon-size text-olive "></text>
				</view>
			</view>

			<view class="padding-left padding-right cu-list menu">
				<view class="cu-item">
					<view class="content">
						<!-- <text class="cuIcon-subscription text-grey"></text> -->
						<text class="text-grey ">栏位号</text>
					</view>
					<view v-if="edit_permission" @tap="showModelHnum" class="action">
						<text class="text-olive ">{{hnum}}</text>
					</view>
					<view v-if="!edit_permission" class="action">
						<text class="text-grey ">{{hnum}}</text>
					</view>
				</view>

				<view class="cu-item">
					<view class="content">
						<!-- <text class="cuIcon-subscription text-grey"></text> -->
						<text class="text-grey ">饲喂模式</text>
					</view>
					<view class="action">
						<text class="text-grey ">{{mode_str}}</text>
					</view>
				</view>

				<view class="cu-item" v-if=" mode!=5">
					<view class="content">
						<text class="text-grey ">日龄</text>
					</view>
					<view v-if="setparam_permission" @tap="showModelDay" class="action">
						<text class="text-olive ">{{day}}</text>
					</view>
					<view v-if="!setparam_permission" class="action">
						<text class="text-grey ">{{day}}</text>
					</view>
				</view>

				<view class="cu-item">
					<view class="content">
						<!-- <text class="cuIcon-subscription text-grey"></text> -->
						<text class="text-grey ">猪只个数</text>
					</view>
					<view v-if="edit_permission" @tap="goToPig" class="action">
						<text class="text-olive ">{{pig_num}}</text>
					</view>
					<view v-if="!edit_permission" class="action">
						<text class="text-grey ">{{pig_num}}</text>
					</view>
				</view>

				<view class="cu-item" v-if="mode==2">
					<view class="content">
						<text class="text-grey ">带仔个数</text>
					</view>
					<view v-if="edit_permission" @tap="goToPig" class="action">
						<text class="text-olive ">{{son}}</text>
					</view>
					<view v-if="!edit_permission" class="action">
						<text class="text-grey ">{{son}}</text>
					</view>
				</view>

				<view class="cu-item">
					<view class="content">
						<!-- <text class="cuIcon-subscription text-grey"></text> -->
						<text class="text-grey ">饲喂方案</text>
					</view>
					<view v-if="setparam_permission" class="action">
						<text class="text-grey ">{{feed_plan_name_new}}</text>
					</view>
					<view v-if="!setparam_permission" class="action">
						<text class="text-grey ">{{feed_plan_name_new}}</text>
					</view>
				</view>

				<view class="cu-item">
					<view class="content">
						<!-- <text class="cuIcon-subscription text-grey"></text> -->
						<text class="text-grey ">饲喂器SN</text>
					</view>
					<view class="action">
						<text class="text-grey ">{{sn}}</text>
					</view>
				</view>

				<view class="cu-item">
					<view class="content">
						<!-- <text class="cuIcon-subscription text-grey"></text> -->
						<text class="text-grey ">饲喂器版本号</text>
					</view>
					<view class="action">
						<text class="text-grey ">{{version}}</text>
					</view>
				</view>
			</view>

			<view class="cu-bar solid-bottom margin-top">
				<view class="action">
					<text class="cuIcon-titles text-olive"></text>
					<text class="text-white text-md">采食历史</text>
				</view>
				<view class="action">
					<view class="">
						<button @tap="onTabHisType('7')" :class="hisType=='7'?'':'line-grey'"
							class="cu-btn bg-olive shadow sm margin-right-xxs">7日</button>
						<button @tap="onTabHisType('30')" :class="hisType=='30'?'':'line-grey'"
							class="cu-btn bg-olive  shadow sm margin-right-xxs">30日</button>
					</view>
				</view>
			</view>
			<view class="padding-sm" style="height: 500rpx">
				<l-echart ref="chart"></l-echart>
			</view>

		</scroll-view>



		<view class="cu-modal bottom-modal" :class="showMenu?'show':''" @tap="hideModal">
			<view class="cu-dialog">
				<!-- <view class="cu-bar bg-white">
									<view class="action text-green" @tap="hideModal">确定</view>
									<view class="action text-gray" @tap="hideModal">取消</view>
								</view> -->
				<view class="">
					<view class="cu-list menu">
						<view v-if="edit_permission" class="cu-item arrow" @tap="onMenu('pig')">
							<view class="content">
								<text class="iconfont icon-pig2 text-grey"></text>
								<text class="text-grey padding-left-xs">猪只维护</text>
							</view>
						</view>
						<view v-if="edit_permission" class="cu-item arrow" @tap="onMenu('hnum')">
							<view class="content">
								<text class="iconfont icon-lan text-grey"></text>
								<text class="text-grey padding-left-xs">修改栏位号</text>
							</view>
						</view>
						<view v-if="manulfeed_permission" class="cu-item arrow" @tap="onMenu('feed')">
							<view class="content">
								<text class="iconfont icon-feed1 text-grey"></text>
								<text class="text-grey padding-left-xs">下料/下水</text>
							</view>
						</view>

						<view v-if="setparam_permission" class="cu-item arrow" @tap="onMenu('offset')">
							<view class="content">
								<text class="cuIcon-order text-grey"></text>
								<text class="text-grey">调整料量</text>
							</view>
						</view>

						<view v-if="setparam_permission" class="cu-item arrow" @tap="onMenu('calc')">
							<view class="content">
								<text class="cuIcon-focus text-grey"></text>
								<text class="text-grey">下料校准</text>
							</view>
						</view>



						<!-- <view v-if="mode==1" class="cu-item arrow" @tap="onMenu('born')">
							<view class="content">
								<text class="cuIcon-female text-grey"></text>
								<text class="text-grey">一键分娩</text>
							</view>
						</view> -->
						<view v-if="setparam_permission" class="cu-item arrow" @tap="onMenu('day')">
							<view class="content">
								<text class="cuIcon-time text-grey"></text>
								<text class="text-grey">设置日龄</text>
							</view>
						</view>
						<view v-if="setparam_permission" class="cu-item arrow" @tap="onMenu('plan')">
							<view class="content">
								<text class="cuIcon-tag text-grey"></text>
								<text class="text-grey">应用方案</text>
							</view>
						</view>
						<view v-if="setparam_permission" class="cu-item arrow" @tap="onMenu('stop')">
							<view class="content">
								<text class="cuIcon-stop text-grey"></text>
								<text class="text-grey">停止饲喂</text>
							</view>
						</view>
					</view>


				</view>
			</view>
		</view>

		<view class="cu-modal bottom-modal" :class="showMenuHnum?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">

					<view class="action text-gray" @tap="hideModalHnum">取消</view>
					<view class="action text-green" @tap="confirmSetHnum">确定</view>
				</view>

				<view class="padding flex justify-begin">
					<text class="iconfont icon-tishi1 text-green"></text>
					<text class="text-md text-grey text-sm">请选取字母排号和数字列号组合，如A排+7列=A007</text>
				</view>

				<view class="padding flex align-center justify-center">
					<text class="text-green text-xxl">{{ set_hnum_prefix }}{{ set_hnum }}</text>
				</view>

				<view class="padding flex align-center">
					<view class=" flex-sub text-left text-grey">排号</view>
					<view class="flex-treble align-center">
						<button @tap="onTabHnumPrefix('A')" :class="set_hnum_prefix=='A'?'':'line-grey'"
							class="cu-btn bg-green shadow sm margin-right-xs">A</button>
						<button @tap="onTabHnumPrefix('B')" :class="set_hnum_prefix=='B'?'':'line-grey'"
							class="cu-btn bg-green shadow sm margin-right-xs">B</button>
						<button @tap="onTabHnumPrefix('C')" :class="set_hnum_prefix=='C'?'':'line-grey'"
							class="cu-btn bg-green  shadow sm margin-right-xs">C</button>
						<button @tap="onTabHnumPrefix('D')" :class="set_hnum_prefix=='D'?'':'line-grey'"
							class="cu-btn bg-green  shadow sm margin-right-xs">D</button>
						<button @tap="onTabHnumPrefix('E')" :class="set_hnum_prefix=='E'?'':'line-grey'"
							class="cu-btn bg-green  shadow sm margin-right-xs">E</button>
						<button @tap="onTabHnumPrefix('F')" :class="set_hnum_prefix=='F'?'':'line-grey'"
							class="cu-btn bg-green  shadow sm margin-right-xs">F</button>
						<button @tap="onTabHnumPrefix('G')" :class="set_hnum_prefix=='G'?'':'line-grey'"
							class="cu-btn bg-green  shadow sm margin-right-xs">G</button>
					</view>
				</view>

				<view class="padding flex align-center">
					<view class=" flex-sub text-left text-grey">列号</view>
					<view class=" flex-treble text-right justify-center">
						<slider :value="set_hnum" block-size="20" step="1" @change="hnumSliderChange" min="1"
							max="50" activeColor="#39b54a" block-color="#39b54a" show-value />
					</view>
				</view>

				<view class="padding flex align-center">
					
				</view>

				<view class="padding flex align-center">
					
				</view>
			</view>
		</view>

		<view class="cu-modal bottom-modal" :class="showMenuFeed?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">

					<view class="action text-gray" @tap="hideModalFeed">取消</view>
					<view class="action text-green" @tap="confirmSetFeed">确定</view>
				</view>

				<view class="padding flex justify-begin">
					<text class="iconfont icon-tishi1 text-green"></text>
					<text class="text-md text-grey text-sm">数值0表示不进行下料/下水</text>
				</view>

				<view class="padding flex align-center">
					<view class=" flex-sub text-left text-grey">下料(g):</view>
					<view class=" flex-treble text-right justify-center">
						<slider :value="set_feed" block-size="20" step="50" @change=" feedSliderChange " min="0"
							max="1000" activeColor="#39b54a" block-color="#39b54a" show-value />
					</view>
				</view>

				<view class="padding flex align-center">
					<view class=" flex-sub text-left text-grey">下水(ml):</view>
					<view class=" flex-treble text-right justify-center">
						<slider :value="set_water" block-size="20" step="50" @change="waterSliderChange" min="0"
							max="1000" activeColor="#39b54a" block-color="#39b54a" show-value />
					</view>
				</view>
			</view>
		</view>

		<view class="cu-modal bottom-modal" :class="showMenuOffset?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">

					<view class="action text-gray" @tap="hideModalOffset">取消</view>
					<view class="action text-green" @tap="confirmSetOffset">确定</view>
				</view>

				<view class="padding flex justify-begin">
					<text class="iconfont icon-tishi1 text-green"></text>
					<text class="text-md text-grey text-sm">设置增加减少饲喂量 </text>
				</view>

				<view class="padding flex align-center">
					<view class=" flex-sub text-left text-grey">增加/减少(g):</view>
					<view class=" flex-treble text-right justify-center">
						<slider :value="set_offset" block-size="20" step="100" @change=" offsetSliderChange "
							min="-1000" max="1000" activeColor="#39b54a" block-color="#39b54a" show-value />
					</view>
				</view>
			</view>
		</view>

		<view class="cu-modal bottom-modal" :class="showMenuCalc?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">

					<view class="action text-gray" @tap="hideModalCalc">取消</view>
					<view class="action text-green" @tap="confirmSetCalc">确定</view>
				</view>

				<view class="padding flex justify-begin">
					<!-- <text class="iconfont icon-tishi1 text-green"></text> -->
					<text class="text-md text-grey text-sm">请输入10圈出料(g)</text>
				</view>

				<view class="padding">

					<view class="uni-input-wrapper">
						<input v-model="set_calc" class="uni-input"
							style="height: 45px;line-height: 35px;border: 1px solid #aaa;font-size: 20px;border-radius: 10px;"
							 maxlength="5" type="number" placeholder="" />
					</view>
				</view>

				<view class="padding flex justify-begin">

				</view>

			</view>
		</view>

		<view class="cu-modal bottom-modal" :class="showMenuDay?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">

					<view class="action text-gray" @tap="hideModalDay">取消</view>
					<view class="action text-green" @tap="confirmSetDay">确定</view>
				</view>

				<view class="padding flex justify-begin">
					<!-- <text class="iconfont icon-tishi1 text-green"></text> -->
					<text class="text-md text-grey text-sm">请输入日龄</text>
				</view>

				<view class="padding">

					<view class="uni-input-wrapper">
						<input v-model="set_day" class="uni-input"
							style="height: 45px;line-height: 35px;border: 1px solid #aaa;font-size: 20px;border-radius: 10px;"
							 maxlength="4" type="number" placeholder="" />
					</view>
				</view>

				<view class="padding flex justify-begin">

				</view>

			</view>
		</view>

		<view class="cu-modal bottom-modal" :class="showMenuPlan?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white">

					<view class="action text-gray" @tap="hideModalPlan">取消</view>
					<view class="action text-green" @tap="confirmSetPlan">确定</view>
				</view>

				<view class="padding flex justify-begin">
					<text class="iconfont icon-tishi1 text-green"></text>
					<text class="text-md text-grey text-sm">请选择方案后点击[确定]</text>
				</view>

				<view class="padding">
					<scroll-view scroll-y="true" class="scroll-Y " style="height: 500rpx;">
						<block v-for="(item, idx) in planList" :key="idx">
							<view @tap="onPlanSelect(idx)" :class="item.select>0?'bg-select':'bg-unselect'"
								class="device-pannel margin-sm " hover-class="opcity" hover-stay-time="150">
								<view class="padding-sm flex align-center">
									<view class="flex-treble text-left">
										<text v-if="item.global>0"
											class="iconfont icon-moban-xitongmoban text-orange"></text>
										<text class=" text-grey padding-left-xs">{{item.name}}</text>

									</view>
									<view class="flex-sub text-right justify-center">
										<text class="text-grey">{{item.food_plan}}</text>
									</view>
								</view>
							</view>
						</block>
					</scroll-view>
				</view>

				<view class="padding">

				</view>

			</view>
		</view>

	</view>
</template>

<script>
	import * as api from 'common/api.js';
	import * as util from '../../common/util.js'
	const moment = require("../../common/moment.min.js");
	import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
	import {
		API_HEAD
	} from '../../common/api.js';
	import {
		toHandlerKey
	} from "vue";

	const lightGreenColor = "#429c5e";
	const lightOrangeColor = "#f47011";
	const lightOrangeColor1 = "#eab839";
	const lightOrangeColor2 = "#ffee01";
	const titleColor = "#8f97b3";
	const blue = "#4168ff";
	const green = "#31c2b0";
	var day_his_chart_options = {
		// backgroundColor: '#0e1a39',
		legend: {
			show: true,
			x: 'center',
			y: '10',
			icon: 'stack',
			itemWidth: 10,
			itemHeight: 10,
			textStyle: {
				fontSize: 11,
				color: titleColor
			},
			data: [{
				name: '实际饲喂量(kg)',
				icon: 'rect'
			}, {
				name: "目标饲喂量(kg)",
				icon: 'circle'
			}]
		},
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				lineStyle: {
					color: '#ffffff'
				},
			}
		},
		grid: {
			top: '20%',
			left: '5%',
			right: '5%',
			bottom: '15%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			axisLine: {
				show: true
			},
			splitArea: {
				// show: true,
				color: '#f00',
				lineStyle: {
					color: '#f00'
				},
			},
			axisLabel: {
				color: titleColor
			},
			splitLine: {
				show: false
			},
			boundaryGap: false,
			//data: ['A', 'B', 'C', 'D', 'E', 'F'],

		}],
		yAxis: [{
			type: 'value',
			min: 0,
			max: function(value) {
				return value.max + 1;
			},
			splitLine: {
				show: false,
				lineStyle: {
					color: 'rgba(255,255,255,0.1)'
				}
			},
			axisLine: {
				show: false,
			},
			axisLabel: {
				show: true,
				margin: 20,
				textStyle: {
					color: titleColor,

				},
			},
			axisTick: {
				show: true,
			},
		}, {
			type: 'value',
			min: 0,
			max: function(value) {
				return value.max + 1;
			},
			splitLine: {
				show: true,
				lineStyle: {
					color: 'rgba(255,255,255,0.1)'
				}
			},
			axisLine: {
				show: false,
			},
			axisLabel: {
				show: true,
				margin: 20,
				textStyle: {
					color: titleColor,

				},
			},
			axisTick: {
				show: true,
			},
		}],
		series: [{
			name: '实际饲喂量(kg)',
			type: 'bar',
			//barWidth: '10px',
			barMaxWidth: '10px',
			yAxisIndex: 0,
			data: [],
			itemStyle: {
				normal: {
					color: green,
					// barBorderRadius: [30, 30, 30, 30],
					// shadowColor: '#f29725',
					// shadowBlur: 4,
				}
			},
			tooltip: {
				show: true
			}
		}, {
			name: '目标饲喂量(kg)',
			type: 'line',
			smooth: false, //是否平滑
			showSymbol: true,
			yAxisIndex: 1,
			itemStyle: {
				normal: {
					color: lightOrangeColor1,
					lineStyle: {
						width: 1,
						type: 'dotted' //'dotted'虚线 'solid'实线
					},
					borderColor: lightOrangeColor1, //图形的描边颜色。支持的格式同 color
					//borderWidth: 8 ,//描边线宽。为 0 时无描边。[ default: 0 ]
					barBorderRadius: 0,
					label: {
						show: false,
					},
					opacity: 0.5,
				}
			},
			tooltip: {
				show: true
			}
		}]
	}

	export default {
		data() {
			return {
				actions:[],
				edit_permission:false,
				delete_permission:false,
				setparam_permission:false,
				manulfeed_permission:false,

				scrollHeight: 0,
				loading: false,
				showMenu: false,
				showMenuHnum: false,
				showMenuFeed: false,
				showMenuDay: false,
				showMenuCalc: false,
				showMenuOffset: false,
				showMenuPlan: false,
				hisType: '7',

				sn: '',
				addr: '',
				tn: '',

				online: 0,
				alarm: 0,
				alarm_bit0: 0,
				alarm_bit1: 0,
				alarm_bit2: 0,
				alarm_bit3: 0,
				alarm_bit4: 0,
				alarm_bit5: 0,
				alarm_bit6: 0,
				alarm_bit7: 0,

				alarm_ext: 0,
				hnum:'',
				mode: '',
				mode_str: '',
				mode_day: '',
				day: '',
				day_use_water_auto: 0,
				day_use_water_man: 0,
				day_use_feed_auto: 0,
				day_use_feed_man: 0,
				water: 0,
				feed: 0,
				max_feed: 0,
				pig_num: 0,
				son: 0,

				feed_alarm_diff: 0, //采食量预警偏移(单位kg)
				feed_plan_id: null,
				feed_plan_name_new: '',
				house_type: '',
				para: {},
				status: {},
				version: '',


				date: moment().format('YYYY-MM-DD'),
				has_next_day: false,
				has_pre_day: true,

				hisList: [],
				hisItem: {
					mode: '',
					mode_str: '',
					mode_day: '',
					feed: 0,
					max_feed: 0,
				},

				set_hnum: 1,
				set_hnum_prefix: 'A',
				set_feed: 100,
				set_water: 0,
				set_day: 1,
				set_offset: 0,
				set_calc: 1000,

				planList: [],

				node:{},
			}
		},
		onReady() {
			// 计算scroll-view高度
			uni.getSystemInfo({
				success: resu => {
					//console.info("窗口高度:", resu.windowHeight)
					const query = uni.createSelectorQuery()
					query.select('.title').boundingClientRect()
					query.exec(res => {

						//console.info("顶部下拉区域:", res[0])
						this.scrollHeight = resu.windowHeight - res[0].height - 10 + 'px';
						//console.log('剩余高度', this.scrollHeight);
					})
				}
			})
		},
		onShow: function() {
			console.info("show feednode")
			this.loadAll()
		},
		onLoad(option) {
			console.info("load feednode", option)
			if (option.sn != '') {
				this.sn = option.sn
				this.loadAll()
			}

			var that = this
			getApp().getActions("/Device/FeedNodesNew").then(function(res){
				if (res.code >= 0) {
					that.actions = res.data
					that.edit_permission = false
					that.setparam_permission = false
					that.delete_permission = false
					that.manulfeed_permission =false
					for(var i=0;i<that.actions.length;i++){
						if(that.actions[i].action_id=='edit'){
							that.edit_permission = true
						}
						if(that.actions[i].action_id=='setparam'){
							that.setparam_permission = true
						}
						if(that.actions[i].action_id=='delete'){
							that.delete_permission = true
						}
						if(that.actions[i].action_id=='manulfeed'){
							that.manulfeed_permission = true
						}
					}
					//console.info(that.setparam_permission)
				}
			})

			var is_admin = getApp().isAdmin()
			console.info("is_admin",is_admin)
		},
		methods: {
			showModal() {
				if(!this.setparam_permission && !this.edit_permission && !this.manulfeed_permission){
					uni.showToast({
						title: '您没有权限',
						icon: 'none'
					})
				}else{
					this.showMenu = true
				}
			},
			showModelHnum() {
				this.showMenuHnum = true
				this.set_hnum = this.hnum.substring(1)
				this.set_hnum_prefix = this.hnum.substring(0,1)
			},
			showModelFeed() {
				this.showMenuFeed = true
				this.set_feed = 100
				this.set_water = 0
			},
			showModelOffset() {
				this.showMenuOffset = true
				var para = JSON.parse(this.para)
				console.info(para.FeedOffset)
				this.set_offset = para.FeedOffset * 100
			},
			showModelDay() {
				this.showMenuDay = true
				this.set_day = this.day
			},
			showModelCalc() {
				this.showMenuCalc = true
				var para = JSON.parse(this.para)
				console.info(para.CalFeed)
				this.set_calc = para.CalFeed
			},
			showModelPlan() {
				this.showMenuPlan = true
				this.loadPlan()
			},
			goToPig(){
				console.info(JSON.stringify(this.node))
				uni.navigateTo({
					url: "/pages/set_pig/set_pig?from=" + "feednode" + "&farmid=" + this.node.farmid+ "&farmname=" + this.node.farmname + "&houseid=" + this.node.houseid+ "&housename=" + this.node.housename+ "&hnum=" + this.node.hnum+ "&sn=" + this.node.sn
					+ "&pig_num=" + this.node.pig_num
					+ "&son=" + this.node.son
					+ "&mode=" + this.node.mode
				})
			},
			hideModal() {
				console.info("hideModal")
				this.showMenu = false
			},
			hideModalHnum() {
				this.showMenuHnum = false
			},
			hideModalFeed() {
				this.showMenuFeed = false
			},
			hideModalOffset() {
				this.showMenuOffset = false
			},
			hideModalDay() {
				this.showMenuDay = false
			},
			hideModalCalc() {
				this.showMenuCalc = false
			},
			hideModalPlan() {
				this.showMenuPlan = false
			},
			hnumSliderChange(e) {
				console.log('hnum value 发生变化：' + e.detail.value)
				let num = e.detail.value
				if(num<10){
					this.set_hnum = "00"+num.toString()
				}else if(num<100){
					this.set_hnum = "0"+num.toString()
				}else{
					this.set_hnum = num.toString()
				}
				//this.set_hnum = e.detail.value.padStart(3, '0')
			},
			waterSliderChange(e) {
				console.log('water value 发生变化：' + e.detail.value)
				this.set_water = e.detail.value
			},
			feedSliderChange(e) {
				console.log('feed value 发生变化：' + e.detail.value)
				this.set_feed = e.detail.value
			},
			offsetSliderChange(e) {
				console.log('offset value 发生变化：' + e.detail.value)
				

				this.set_offset = e.detail.value
			},
			onTabHnumPrefix(str){
				this.set_hnum_prefix = str
			},
			onMenu(type) {
				console.info("onMenu", type)
				if (type == 'pig') {
					this.goToPig()
				}
				else if (type == 'hnum') {
					this.showModelHnum()
				}
				else if (type == 'feed') {
					this.showModelFeed()
				} else if (type == 'offset') {
					this.showModelOffset()
				} else if (type == 'day') {
					this.showModelDay()
				} else if (type == 'calc') {
					this.showModelCalc()
				} else if (type == 'stop') {
					this.confirmSetStop()
				} else if (type == 'plan') {
					this.showModelPlan()
				} else {
					uni.showToast({
						title: '您没有权限',
						icon: 'error'
					})
				}

			},
			onPlanSelect(idx) {
				console.info("onPlanSelect", idx)
				for (var i = 0; i < this.planList.length; i++) {
					this.planList[i].select = 0
				}
				this.planList[idx].select = 1
				this.$forceUpdate()
			},
			onTabHisType(val) {
				this.hisType = val
				this.loadHis()
			},
			onPreDay() {
				this.date = moment(this.date).add(-1, 'days').format('YYYY-MM-DD')
				var date = moment(this.date)
				var today = moment(moment().format('YYYY-MM-DD'))
				if (date.isBefore(today)) {
					this.has_next_day = true
				} else {
					this.has_next_day = false
				}
				this.loadHisItem()
			},
			onNextDay() {

				var date = moment(this.date)
				var today = moment(moment().format('YYYY-MM-DD'))
				if (date.isBefore(today)) {

					this.date = moment(this.date).add(1, 'days').format('YYYY-MM-DD')
					if (moment(this.date).isBefore(today)) {
						this.has_next_day = true
					} else {
						this.has_next_day = false
					}
				} else {
					this.has_next_day = false
				}
				this.loadHisItem()
			},
			loadAll() {
				this.loadFeedNode()
				this.loadHisItem()
				this.loadHis()
			},
			loadFeedNode() {
				var that = this
				var token = getApp().getToken()
				api.myRequest({
					url: '/Api/Device/Feednode',
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authorization': 'Bearer ' + token + ''
					},
					data: {
						sn: that.sn,
					},
				}, false).then(res => {
					if (res.code >= 0) {
						var list = res.data;
						if (list.length > 0) {
							var item = list[0];
							that.node = item
							that.online = item.online
							if (!that.online) {
								that.online = 0
							}
							that.alarm = item.alarm
							that.alarm_bit0 = util.getByteBit(item.alarm,0)
							that.alarm_bit1 = util.getByteBit(item.alarm,1)
							that.alarm_bit2 = util.getByteBit(item.alarm,2)
							that.alarm_bit3 = util.getByteBit(item.alarm,3)
							that.alarm_bit4 = util.getByteBit(item.alarm,4)
							that.alarm_bit5 = util.getByteBit(item.alarm,5)
							that.alarm_bit6 = util.getByteBit(item.alarm,6)
							that.alarm_bit7 = util.getByteBit(item.alarm,7)
							that.alarm_ext = item.alarm_ext
							that.sn = item.sn
							that.addr = item.addr
							that.tn = item.tn
							that.hnum = item.hnum
							that.mode = item.mode
							that.model = item.model
							if(!that.model || that.model=="feed"||that.model==""){
								that.mode_str = util.decodeModeNew(item.mode)
								if (item.mode == 0 || item.mode == 5) {
									that.day = 'N/A'
									that.mode_day = that.mode_str
								} else {
									that.mode_day = that.mode_str + ' ' + item.day + '天'
								}
								
							}else if(that.model && that.model=="fg"){
								that.mode_str = util.decodeFg(item.mode)
								if (item.mode == 0 || item.mode == 5) {
									that.day = 'N/A'
									that.mode_day = that.mode_str
								} else {
									that.mode_day = that.mode_str + ' ' + item.day + '天'
								}
							}
							
							
							that.day = item.day

							that.day_use_water_auto = item.day_use_water_auto ? item.day_use_water_auto : 0
							that.day_use_water_man = item.day_use_water_man ? item.day_use_water_man : 0
							that.day_use_feed_auto = item.day_use_feed_auto ? item.day_use_feed_auto : 0
							that.day_use_feed_man = item.day_use_feed_man ? item.day_use_feed_man : 0
							that.max_feed = item.max_feed ? parseFloat(item.max_feed) : 0

							that.pig_num = item.pig_num ? item.pig_num : 0
							that.son = item.son ? item.son : 0

							var water = parseFloat(item.day_use_water_auto) + parseFloat(item
								.day_use_water_man)
							that.water = parseFloat(water.toFixed(2).toString()).toString();

							var feed = parseFloat(item.day_use_feed_auto) + parseFloat(item.day_use_feed_man)
							that.feed = parseFloat(feed.toFixed(2).toString()).toString();
							if (isNaN(that.feed)) {
								that.feed = 0
							}

							var per = 0
							if (item.max_feed > 0) {
								per = parseFloat((feed / parseFloat(item.max_feed) * 100).toFixed(1))
							} else {
								per = 0
							}
							that.per = per

							that.feed_alarm_diff = item.feed_alarm_diff ? item.feed_alarm_diff : 0
							that.feed_plan_id = item.feed_plan_id ? item.feed_plan_id : 0
							that.feed_plan_name_new = item.feed_plan_name_new ? item.feed_plan_name_new : ''
							that.house_type = item.house_type ? item.house_type : ''
							that.para = item.para
							that.status = item.status
							that.version = item.version

							uni.setNavigationBarTitle({
								title: item.housename + " " + item.hnum + '栏'
							});
						}

					} else {

					}
				}).catch(err => {
					console.log(err)
				})
			},
			loadHisItem() {
				var begin = this.date
				var end = moment(this.date).add(1, "days").format('YYYY-MM-DD')

				var that = this
				var token = getApp().getToken()
				api.myRequest({
					url: '/Api/History/StatusHis',
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authorization': 'Bearer ' + token + ''
					},
					data: {
						sn: that.sn,
						begin: begin,
						end: end,
						order: 'his_date asc '
					},
				}, false).then(res => {
					if (res.code >= 0) {
						var list = res.data;
						if (list.length > 0) {
							var item = list[0]
							
							that.model = item.model
							if(!that.model || that.model=="feed"||that.model==""){
								that.hisItem.mode_str = util.decodeModeNew(item.mode)
								if (item.mode == 0 || item.mode == 5) {
									that.hisItem.mode_day = that.hisItem.mode_str
								} else {
									that.hisItem.mode_day = that.hisItem.mode_str + ' ' + item.day + '天'
								}
								
							}else if(that.model && that.model=="fg"){
								that.hisItem.mode_str = util.decodeFg(item.mode)
								if (item.mode == 0 || item.mode == 3) {
									that.hisItem.mode_day = that.hisItem.mode_str
								} else {
									that.hisItem.mode_day = that.hisItem.mode_str + ' ' + item.day + '天'
								}
							}
							
							

							that.hisItem.day_use_water_auto = item.day_use_water_auto ? item.day_use_water_auto : 0
							that.hisItem.day_use_water_man = item.day_use_water_man ? item.day_use_water_man : 0
							that.hisItem.day_use_feed_auto = item.day_use_feed_auto ? item.day_use_feed_auto : 0
							that.hisItem.day_use_feed_man = item.day_use_feed_man ? item.day_use_feed_man : 0
							that.hisItem.max_feed = item.max_feed ? parseFloat(item.max_feed) : 0
							var feed = parseFloat(item.day_use_feed_auto) + parseFloat(item.day_use_feed_man)
							that.hisItem.feed = parseFloat(feed.toFixed(2).toString()).toString();
							if (isNaN(that.hisItem.feed)) {
								that.hisItem.feed = 0
							}
						}else{
							that.hisItem.mode_str = 'N/A'
							that.hisItem.mode_day = 'N/A'
							that.hisItem.max_feed = 'N/A'
							that.hisItem.feed = 'N/A'
						}
					} else {
						
						that.hisItem.mode_str = 'N/A'
						that.hisItem.mode_day = 'N/A'
						that.hisItem.max_feed = 'N/A'
						that.hisItem.feed = 'N/A'
					}
				}).catch(err => {
					console.log(err)
				})
			},
			loadHis() {
				var begin = ''
				var end = ''
				if (this.hisType == '7') {
					begin = moment().add(-7, "days").format('YYYY-MM-DD')
					end = ''
				} else if (this.hisType == '30') {
					begin = moment().add(-30, "days").format('YYYY-MM-DD')
					end = ''
				}
				var that = this
				var token = getApp().getToken()
				api.myRequest({
					url: '/Api/History/StatusHis',
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authorization': 'Bearer ' + token + ''
					},
					data: {
						sn: that.sn,
						begin: begin,
						end: end,
						order: 'his_date asc '
					},
				}, false).then(res => {
					if (res.code >= 0) {
						var list = res.data;
						that.hisList = list
						that.showChart()
					} else {

					}
				}).catch(err => {
					console.log(err)
				})
			},
			showChart() {
				var that = this


				that.$refs.chart.init(echarts, chart => {
					var day_arr = [];
					var val_arr = [];
					var val1_arr = [];

					var max = 0;

					//console.info(res.data)
					for (var i = 0; i < that.hisList.length; i++) {
						var his = that.hisList[i];
						var feed = parseFloat(his.day_use_feed_auto) + parseFloat(his.day_use_feed_man);
						var max_feed = parseFloat(his.max_feed);

						if (max < feed) {
							max = feed;
						}
						if (max < max_feed) {
							max = max_feed;
						}
						val_arr.push(parseFloat(feed.toFixed(2)));
						val1_arr.push(max_feed);
						day_arr.push(moment(his.his_date).format("MM/DD"));
					}
					day_his_chart_options.series[0].data = val_arr;
					day_his_chart_options.series[1].data = val1_arr;
					day_his_chart_options.xAxis[0].data = day_arr;
					//day_his_chart_options.yAxis[0].min = 0;
					//day_his_chart_options.yAxis[1].min = 0;
					//day_his_chart_options.yAxis[0].max = parseFloat((max * 1.2).toFixed(2));
					//day_his_chart_options.yAxis[1].max = parseFloat((max * 1.2).toFixed(2));

					setTimeout(function() {
						chart.setOption(day_his_chart_options);
						chart.resize();
					}, 200);
				});
			},
			confirmSetHnum(){
				var that = this
				var hnum = that.set_hnum_prefix + that.set_hnum
				that.hideModalHnum()
				uni.showModal({
					title: '提示',
					content: '请注意,您即将对' + that.hnum + '栏设置栏位号:' + hnum + ' ,您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: '/Api/Device/Gw/SetNodeHnum',
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									hnum: hnum,
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '设置成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 5 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			confirmSetFeed() {
				var that = this
				that.hideModalFeed()
				uni.showModal({
					title: '提示',
					content: '请注意,您即将对' + that.hnum + '栏远程下料:' + that.set_feed + 'g,远程下水:' + that
						.set_water + ' ml,您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: '/Api/Device/Gw/ManualFeed',
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									feed: that.set_feed,
									water: that.set_water
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '远程操作成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 5 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			confirmSetOffset() {
				var that = this
				that.hideModalOffset()
				uni.showModal({
					title: '提示',
					content: '请注意,您即将对' + that.hnum + '栏 设置增加/减少料量:' + that.set_offset + 'g' + ',您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: '/Api/Device/Gw/SetNodeFeedOffset',
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									feedOffset: that.set_offset / 100
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '设置成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 5 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			confirmSetDay() {
				var that = this
				that.hideModalDay()
				uni.showModal({
					title: '请注意',
					content: '您即将对' + that.hnum + '栏设置日龄:' + that.set_day + ',您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: '/Api/Device/Gw/SetNodeDay',
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									day: that.set_day
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '设置成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 5 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			confirmSetCalc() {
				var that = this
				that.hideModalCalc()
				uni.showModal({
					title: '请注意',
					content: '您即将对' + that.hnum + '栏设置10圈出料(g):' + that.set_calc + ',您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: '/Api/Device/Gw/SetNodeCalcFeed',
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									calFeed: that.set_calc
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '设置成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 10 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			confirmSetStop() {
				var that = this
				var model = that.node.model;
				console.info("model:",model)
				uni.showModal({
					title: '请注意',
					content: '您即将对' + that.hnum + '栏停止自动饲喂,您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: '/Api/Device/Gw/SetNodeMode',
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									mode: 0,
									model:model
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '设置成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 10 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			updateGwParam() {
				var that = this
				var token = getApp().getToken()
				that.loading = true
				api.myRequest({
					url: '/Api/Device/Gw/Param',
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authorization': 'Bearer ' + token + ''
					},
					data: {
						addr: that.addr
					},
				}, false).then(res => {
					that.loading = false
					if (res.code >= 0) {
						console.info("刷新设备参数成功,后台数据会自动刷新")
					} else {

					}
				}).catch(err => {
					that.loading = false
					console.log(err)
				})
			},
			updateGwStatus() {
				var that = this
				var token = getApp().getToken()
				that.loading = true
				api.myRequest({
					url: '/Api/Device/Gw/Status',
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authorization': 'Bearer ' + token + ''
					},
					data: {
						addr: that.addr
					},
				}, false).then(res => {
					that.loading = false
					if (res.code >= 0) {
						console.info("刷新设备状态成功,后台数据会自动刷新")
					} else {

					}
				}).catch(err => {
					that.loading = false
					console.log(err)
				})
			},
			loadPlan() {
				var that = this
				var token = getApp().getToken()
				that.loading = true
				api.myRequest({
					url: '/Api/FeedPlanNew',
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authorization': 'Bearer ' + token + ''
					},
					data: {

					},
				}, false).then(res => {
					that.loading = false
					if (res.code >= 0) {
						that.planList = res.data
					} else {

					}
				}).catch(err => {
					that.loading = false
					console.log(err)
				})
			},
			confirmSetPlan() {
				var that = this
				var idx = -1
				for (var i = 0; i < that.planList.length; i++) {
					if (that.planList[i].select == 1) {
						idx = i
						break
					}
				}

				if (idx < 0) {
					//that.hideModalPlan()
					console.info("idx:未选择", idx)
					uni.showToast({
						title: '请先选择方案',
						icon: 'error'
					})
					// uni.showModal({
					// 	title: '提示',
					// 	content: '请选选择方案',
					// 	showCancel: false
					// })
				} else {

					var plan = that.planList[idx]
					console.info("plan para:",plan.para)
					console.info("old para:",that.para)
					console.info('feed_plan_id:',plan.id)
					//备份不被覆盖的参数
					var plan_para = JSON.parse(plan.para)
					var old_para = JSON.parse(that.para)
					var Sn = old_para.Sn
					var Passwd = old_para.Passwd
					var Gday = old_para.Gday
					var Hnum = old_para.Hnum
					
					var new_para =JSON.parse(JSON.stringify(plan_para))
					new_para.Sn = Sn
					new_para.Passwd = Passwd
					new_para.Gday = Gday
					new_para.Hnum = Hnum
					
					that.setParam(plan,new_para)
				}

			},
			
			setParam(plan,para){
				var that = this
				var model = that.node.model;
				console.info("model:",model)
				var url=''
				if(model==""||model=="feed"){
					url = '/Api/Device/Gw/NodeParam'
				}else if(model=="fg"){
					url = '/Api/Device/Gw/NodeFgParam'
				}
				that.hideModalPlan()
				uni.showModal({
					title: '提示',
					content: '请注意,您即将对' + that.hnum + '设置方案:' + plan.name +' ,您的操作将会被系统记录',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							var token = getApp().getToken()
							that.loading = true
							api.myRequest({
								url: url,
								method: 'PUT',
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authorization': 'Bearer ' + token + ''
								},
								data: {
									addr: that.addr,
									tn: that.tn,
									params: JSON.stringify(para),
									enable:'1',
									feed_plan_id: plan.id
								},
							}, false).then(res => {
								that.loading = false
								if (res.code >= 0) {
									uni.showToast({
										title: '操作成功',
										icon: 'success',
										duration: 2000
									});
									setTimeout(function() {
										that.updateGwParam()
									}, 500)
									setTimeout(function() {
										that.loadFeedNode()
									}, 5 * 1000)
								} else {
									uni.showModal({
										title: '失败',
										content: res.msg,
										showCancel: false
									})
								}
							}).catch(err => {
								that.loading = false
								console.log(err)
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style>
	.cu-modal{
		z-index: 2;
	}
	.opcity {
		opacity: 0.8;
	}

	.back_forward_btn {
		min-height: 100px;
		width: 40px;
	}

	.bg-pannel {
		border-radius: 15rpx;
		/* background-color: rgba(100, 100, 100, 0.3); */
		background-color: rgba(230, 230, 230, 0.3);
		box-shadow: 0 2px 4px rgba(100, 100, 155, 0.5);
	}

	.cu-list.menu>.cu-item {
		min-height: 40px;
		background-color: transparent;
	}

	.cu-list.menu>.cu-item:after {
		border-bottom: 0px
	}

	.bg-select {
		background-color: rgba(200, 200, 200, 0.3);
		border: 2px solid #0d8400;
		border-radius: 5px;
	}

	.bg-unselect {
		background-color: rgba(200, 200, 200, 0.3);
		border: 1px solid #dadada;
		border-radius: 5px;
	}
</style>